package com.hy.main.demo.rabbitmq;

import cn.hutool.core.date.DateUtil;
import com.rabbitmq.client.Channel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

import java.nio.charset.StandardCharsets;

/**
 * @Author yang DongYong
 * @Date 2022/5/12 - 05 - 12 - 1:38
 * @Description: com.hy.main.demo.rabbitmq
 * @version: 1.0
 * 死信队列TTL消费者
 */
@Component
@Slf4j
public class DeadQueueConsumer {

    // 接收消息
    @RabbitListener(queues = "QD")
    public void receiveQueueD (Message message, Channel channel) {
        String mes = new String(message.getBody(), StandardCharsets.UTF_8);
        log.info("当前时间{},接收到的消息{}",DateUtil.now(),mes);
        System.out.println("回退测试");
    }

}
